package com.superman.view;

import com.alibaba.fastjson.JSON;
import com.superman.entity.*;
import com.superman.socket.TCPClient;
import com.superman.util.Input;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class AddAndAlter {
    public List<Car_Brand_Category> addCar(Car car){
        List<Car_Brand_Category> list = new ArrayList<>();
        try {
            list = JSON.parseArray(TCPClient.getResponse("addCar#" + JSON.toJSONString(car)), Car_Brand_Category.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return list;
        }
    }

    public List<Car_Brand_Category> alterCarRent(String car_id, String rent){
        List<Car_Brand_Category> list = new ArrayList<>();
        try {
            list = JSON.parseArray(TCPClient.getResponse("alterCarRent#" + car_id + "#" + rent), Car_Brand_Category.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return list;
        }

    }

    public List<Car_Brand_Category> alterCarUseable(String car_id, int useable){
        List<Car_Brand_Category> list = new ArrayList<>();
        try {
            list = JSON.parseArray(TCPClient.getResponse("alterCarUseable#" + car_id + "#" + useable), Car_Brand_Category.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return list;
        }

    }

}
